<?php  
require_once("../include/conn.php");
$oldpwd=md5(trim($_POST["old_pwd"]));
///echo $oldpwd."<br>";
$name=trim($_POST["name"]);
//echo $name."<br>";
$sql_old="SELECT * FROM `bl_admin` WHERE name = '$name' AND password = '$oldpwd'";
/* SELECT * FROM `bl_admin` WHERE name = 'admin' AND pwd = 'asd' 
 */
//echo $sql_old;
$cn_old = mysql_db_query($db_name,$sql_old);
$oldp=mysql_fetch_row($cn_old);
if(!$oldp){

echo ("<script type='text/javascript'> alert('旧密码不正确,你无权修改密码！');history.go(-1);</script>");


}

else {
 $pwd=md5($_POST["pwd"]);

	
$sql_admin="UPDATE `bl_admin` SET `password` = '$pwd' WHERE name = '$name'";
$cn_admin = mysql_db_query($db_name,$sql_admin);

echo "<script language=\"JavaScript\" type=\"text/JavaScript\">";
echo "alert(\"操作已成功!请记住你的新密码:".$_POST['pwd']."!\");";
echo "</script>";



 
echo "<script language='javascript'>";

echo "self.location="."'"."admin_change.php'";
echo "</script>";	  

}


?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


